package com.example.testdemo.coordinator;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.testdemo.R;

/**
 * Created by 颜 on 04.28.028.
 * 动态
 */

public class DynamicFragment extends Fragment {
    private RecyclerView recyclerView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (recyclerView == null){
            recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_dynamic,null);
            recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false));
        }
        initData();
        return recyclerView;
    }

    private void initData() {
        DynamicAdapter adapter = new DynamicAdapter(getActivity());
        adapter.addData("测试数据1");
        adapter.addData("测试数据2");
        adapter.addData("测试数据3");
        adapter.addData("测试数据4");
        adapter.addData("测试数据5");
        adapter.addData("测试数据6");
        adapter.addData("测试数据7");
        adapter.addData("测试数据8");
        adapter.addData("测试数据9");
        adapter.addData("测试数据10");
        adapter.addData("测试数据11");
        adapter.addData("测试数据12");
        adapter.addData("测试数据13");
        adapter.addData("测试数据14");
        adapter.addData("测试数据15");
        adapter.addData("测试数据16");
        adapter.addData("测试数据17");
        adapter.addData("测试数据18");
        adapter.addData("测试数据19");
        adapter.addData("测试数据20");
        adapter.addData("测试数据21");
        adapter.addData("测试数据22");
        adapter.addData("测试数据23");
        adapter.addData("测试数据24");
        adapter.addData("测试数据25");
        adapter.addData("测试数据26");
        adapter.addData("测试数据27");
        adapter.addData("测试数据28");
        adapter.addData("测试数据29");

        recyclerView.setAdapter(adapter);
    }
}
